{extend name="main"}
{block name="style"}
<style type="text/css">
	.flex-lable{width: 140px;color: #6c757d;text-align: right;padding-right: 10px;}
	.w-100px{width: 100px;}
	.import-dialog .el-dialog{display: -webkit-box; -webkit-box-orient: vertical; -webkit-flex-flow: column;}
	.import-dialog .el-dialog .el-dialog__body{-webkit-box-flex: 1; -webkit-flex: 1; flex: 1;overflow-y: auto; }
</style>
{/block}
{block name="body"}
<div class="bg-white p-3">
	<div class="table-responsive py-3 flex">
			<el-upload
			  ref="upload"
			  accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
			  :file-list="[]"
			  :show-file-list="false"
			  :auto-upload="false"
			  :multiple="false"
			  :on-change="readXlsx">
			  <el-button slot="trigger" size="mini" type="primary">选取文件</el-button>
			</el-upload>
		  <div class="px-1"></div>
		  <el-button type="primary" size="mini" @click="initHtml"
		  :disabled="multipleSelection.length<=0">一键匹配({{multipleSelection.length}})</el-button>
		  <el-button type="success" size="mini" @click="addCompanyALL"
		  :disabled="multipleSelection.length<=0">一键导入({{multipleSelection.length}})</el-button>
		  <div class="px-1"></div>
		  <el-link href="__TEMPLATE_STATIC__/xlsx/import_company.xlsx" target="_blank" :underline="false">下载导入模板</el-link>
	</div>
	<div class="table-responsive">
		<el-table
				ref="tableList"
	      :data="tableData"
    		v-loading="search.ajax"
    		style="width: 100%;"
    		header-cell-class-name="table-header-DDE6FB"
    		@selection-change="handleSelectionChange">
			  <el-table-column
				  type="selection"
				  width="55">
			  </el-table-column>
	      <el-table-column
	      	prop="mobile"
	        label="手机号"
	        width="160">
	      </el-table-column>
	      <el-table-column
	      	prop="title"
	        label="企业名称\简称"
	        min-width="200">
		      <template slot-scope="scope">
		      	<div>{{scope.row.title}}</div>
		      	<div class="small">{{scope.row.stitle}}</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	      	prop="title"
	        label="企业属性"
	        width="200">
		      <template slot-scope="scope">
		      	<div class="small">企业性质：{{scope.row.nature}}</div>
		      	<div class="small">融资阶段：{{scope.row.finance}}</div>
		      	<div class="small">所属行业：{{scope.row.industry}}</div>
		      	<div class="small">企业规模：{{scope.row.size_type}}</div>
		      	<div class="small">注册资金：{{scope.row.registered_capital}}</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	      	prop="company_introduction"
	        label="公司介绍"
	        width="200"
	        type="expand">
		      <template slot-scope="scope">
		      	<div>公司简介：{{scope.row.company_introduction}}</div>
		      	<div class="pt-3">公司介绍：{{scope.row.company_descript}}</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	      	prop="title"
	        label="联系信息"
	        width="400">
		      <template slot-scope="scope">
		      	<div class="small">联系人：{{scope.row.contacts}}</div>
		      	<div class="small">联系电话：{{scope.row.contacts_mobile}}</div>
		      	<div class="small">固定电话：{{scope.row.contacts_tel}}</div>
		      	<div class="small">联系邮箱：{{scope.row.contacts_email}}</div>
		      	<div class="small">所在地区：{{scope.row.area}}</div>
		      	<div class="small">详细地址：{{scope.row.contacts_address}}</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="状态"
	        width="100">
		      <template slot-scope="scope">
		      	<div class="small">
							<div class="text-secondary" v-if="scope.row.status===0">等待匹配</div>
							<div class="text-primary" v-else-if="scope.row.status===1">等待入库</div>
							<div class="text-danger" v-else-if="scope.row.status===2">数据异常
							  <el-popover
							    placement="left"
							    width="200"
							    trigger="hover">
							    <p v-for="msg in scope.row.dataMessage">{{msg}}</p>
							    <i class="el-icon-warning-outline ml-1" slot="reference"></i>
							  </el-popover>
							</div>
							<div class="text-success" v-else-if="scope.row.status===3">入库完成</div>
							<div class="text-info" v-else-if="scope.row.status===4">入库异常
						    <el-popover :content="scope.row.errorMessage" placement="left"
							    trigger="hover">
						      <i class="el-icon-warning-outline ml-1" slot="reference"></i>
						    </el-popover>
						  </div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="/"
	        width="180">
		      <template slot-scope="scope">
		        <el-button
		            type="primary"
		            plain
		            round
		            size="minism"
		            @click="matchingCompany(scope.row)">
		            匹配
		        </el-button>
		        <el-button
		            type="success"
		            plain
		            round
		            size="minism"
		            :disabled="scope.row.status!==1"
		            @click="toggleSelection([tableData[scope.$index]]);addCompanyALL()">
		            导入
		        </el-button>
		        <el-button
		            type="primary"
		            plain
		            round
		            size="minism"
		            :disabled="scope.row.status===0"
		            @click="editCompany(scope)">
		            编辑
		        </el-button>
		      </template>
	      </el-table-column>
	    </el-table>
	</div>
	<div class="table-responsive py-3 text-center">
		<el-pagination
		  background
	      @size-change="handleSizeChange"
	      @current-change="handleCurrentChange"
	      :current-page="search.page"
	      :page-sizes="[10,50,100,200,500,1000]"
	      :page-size="search.pageSize"
	      layout="total, sizes, prev, pager, next, jumper"
	      :total="search.total">
	    </el-pagination>
	</div>
</div>

<el-dialog
  :visible.sync="drawerHandle"
  :fullscreen="true"
  :before-close="closeDrawerHandle"
  class="import-dialog">
		<div class="px-3 py-2" slot="title">
			<el-tabs v-model="activeName" class="bg-white">
				<el-tab-pane label="用户信息" name="user"></el-tab-pane>
				<el-tab-pane label="基本信息" name="basic"></el-tab-pane>
				<el-tab-pane label="企业简介" name="descript"></el-tab-pane>
				<el-tab-pane label="拓展信息" name="content"></el-tab-pane>
				<el-tab-pane label="套餐" name="package"></el-tab-pane>
			</el-tabs>
		</div>
		<el-form :model="rowData" @submit.native.prevent="submitForm" :rules="rules" ref="rowData" label-width="120px" :label-position="labelPosition" v-if="rowData">
			<div v-show="activeName=='user'">
		  <el-form-item label="手机号" prop="mobile">
		    <el-input v-model="rowData.mobile" class="col-12 col-sm-2 pl-0 pr-0" placeholder="Mobile" maxlength="11"></el-input>
		  </el-form-item>

		  <el-form-item label="邮箱" prop="email">
		    <el-input v-model="rowData.email" class="col-12 col-sm-2 pl-0 pr-0" placeholder="Email"></el-input>
		  </el-form-item>

		  <el-form-item label="密码" prop="password">
		    <el-input v-model="rowData.password" class="col-12 col-sm-2 pl-0 pr-0" placeholder="Password" maxlength="20"></el-input>
		  </el-form-item>
			</div>
			<div v-show="activeName=='basic'">
		  <el-form-item label="企业名称" prop="title">
		    <el-input v-model="rowData.title" class="col-12 col-sm-3 pl-0 pr-0" placeholder="Title" maxlength="30" show-word-limit></el-input>
		  </el-form-item>

		  <el-form-item label="企业简称" prop="stitle">
		    <el-input v-model="rowData.stitle" class="col-12 col-sm-3 pl-0 pr-0" placeholder="Stitle" maxlength="20" show-word-limit></el-input>
		  </el-form-item>

		  <el-form-item label="企业认证" prop="attestation">
		    <el-radio-group v-model="rowData.attestation">
		      <el-radio v-for="v in attestation" :label="v.value">{{v.title}}</el-radio>
		    </el-radio-group>
		  </el-form-item>

		  <el-form-item label="营业执照" prop="business_license">
			  <el-image
			  	v-if="business_license" 
			  	class="w-200px h-200px"
			    :src="business_license"
			    :preview-src-list="[business_license]"
			    fit="scale-down">
			  </el-image>
		  	  <el-upload
				  class="avatar-uploader"
				  action="/uploadFiles"
				  name="file"
				  accept="image/*"
				  :data="{path:'company/business_license'}"
				  :show-file-list="false"
				  :on-success="handleAvatarSuccess"
				  :on-error="handleAvatarError">
		  			<el-button size="small" type="primary">选择文件</el-button>
			  </el-upload>
		  </el-form-item>

		  <el-form-item label="企业LOGO" prop="logo">
			  <el-image
			  	v-if="logo" 
			  	class="w-200px h-200px"
			    :src="logo" 
			    :preview-src-list="[logo]"
			    fit="scale-down">
			  </el-image>
		  	  <el-upload
				  class="avatar-uploader"
				  action="/uploadFiles"
				  name="file"
				  accept="image/*"
				  :data="{path:'company/logo'}"
				  :show-file-list="false"
				  :on-success="handleAvatarSuccess"
				  :on-error="handleAvatarError">
		  			<el-button size="small" type="primary">选择文件</el-button>
			  </el-upload>
		  </el-form-item>

		  <el-form-item label="企业性质" prop="nature">
		    <el-radio-group v-model="rowData.nature">
		      <el-radio v-for="v in nature" :label="v.value">{{v.title}}</el-radio>
		    </el-radio-group>
		  </el-form-item>

		  <el-form-item label="融资阶段" prop="finance">
		    <el-radio-group v-model="rowData.finance">
		      <el-radio v-for="v in finance" :label="v.value">{{v.title}}</el-radio>
		    </el-radio-group>
		  </el-form-item>

		  <el-form-item label="所属行业" prop="industry_id">
		  	<el-select v-model="rowData.industry_id" filterable clearable default-first-option placeholder="请选择">
			    <el-option
			      v-for="item in industry"
			      :key="item.id"
			      :label="item.title"
			      :value="item.id">
			    </el-option>
			</el-select>
		  </el-form-item>

		  <el-form-item label="公司规模" prop="size_type">
		    <el-radio-group v-model="rowData.size_type">
		      <el-radio v-for="v in size_type" :label="v.value">{{v.title}}</el-radio>
		    </el-radio-group>
		  </el-form-item>

		  <el-form-item label="注册资金" prop="registered_capital">
		    <el-input v-model.number="rowData.registered_capital" class="col-5 col-sm-1 pl-0 pr-0">
			    <template slot="append">万</template>
		    </el-input>
		    <el-radio-group class="ml-0 ml-sm-2" v-model="rowData.registered_capital_type">
		      <el-radio :label="0">人民币</el-radio>
		      <el-radio :label="1">美元</el-radio>
		    </el-radio-group>
		  </el-form-item>

		  <el-form-item label="企业福利" prop="corporate_welfare">
		  	<el-select v-model="rowData.corporate_welfare" filterable multiple default-first-option :multiple-limit="6" placeholder="请选择">
			    <el-option
			      v-for="item in corporate_welfare"
			      :key="item.value"
			      :label="item.title"
			      :value="item.value">
			    </el-option>
			  </el-select>
		  </el-form-item>
			</div>
			<div v-show="activeName=='descript'">
		  <el-form-item label="企业联系人" prop="contacts">
		    <el-input v-model="rowData.contacts" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item label="手机号码" prop="contacts_mobile">
		    <el-input v-model="rowData.contacts_mobile" class="col-12 col-sm-3 pl-0 pr-0" maxlength="11"></el-input>
		  </el-form-item>
		  <el-form-item label="固定电话" prop="contacts_tel">
		  	<div class="flex col-12 col-sm-3 pl-0 pr-0">
		  		<div>
		    		<el-input v-model="tel.area_code" class="w-100px" maxlength="4"></el-input>
		  		</div>
		  		<div class="px-1">-</div>
		  		<div class="flex-1" style="min-width: 150px;">
		    		<el-input v-model="tel.number" maxlength="8"></el-input>
		  		</div>
		  		<div class="px-1">-</div>
		  		<div>
		    		<el-input v-model="tel.extension" class="w-100px" maxlength="6"></el-input>
		  		</div>
		  	</div>
		  </el-form-item>
		  <el-form-item label="联系邮箱" prop="contacts_email">
		    <el-input v-model="rowData.contacts_email" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item label="公司地址" prop="contacts_area">
		    <el-cascader 
		    	v-model="rowData.contacts_area"
		    	placeholder="试试搜索：北京"
		    	filterable
				:props="defaultProps"
		    	:options="arealist"
		    	class="col-12 col-sm-3 pl-0 pr-0">
		    </el-cascader>
		  </el-form-item>
		  <el-form-item label="详细地址" prop="contacts_address">
		    <el-input v-model="rowData.contacts_address" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
			</div>
			<div v-show="activeName=='content'">
		  <el-form-item label="公司网址" prop="company_website">
		    <el-input v-model="rowData.company_website" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item label="公司简介" prop="company_introduction">
		    <el-input type="textarea" v-model="rowData.company_introduction" :autosize="{ minRows: 4, maxRows: 20}" class="col-12 col-sm-3 pl-0 pr-0" maxlength="200" show-word-limit></el-input>
		  </el-form-item>
		  <el-form-item label="公司介绍" prop="company_descript">
		    <el-input v-model="rowData.company_descript" type="textarea":autosize="{ minRows: 8, maxRows: 50}" maxlength="2000" show-word-limit class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
		  <el-form-item label="企业模板" prop="template_id">
		    <el-input v-model="rowData.template_id" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
		  </el-form-item>
			</div>
			<div v-show="activeName=='package'">
		  <el-form-item label="当前套餐">
		    <span v-for="(v,index) in vip" v-if="v.level===rowData.company_vip_level&&v.is_company">{{v.title}}</span>
		  </el-form-item>
		  <el-form-item label="赠送套餐">
		  	<el-radio-group v-model="rowData.vip_level">
			    <el-radio v-for="(v,index) in vip" :label="v.level" v-if="v.level>0&&v.is_company">{{v.title}}</el-radio>
			</el-radio-group>
		  </el-form-item>
			</div>
		</el-form>
  	<div class="flex px-3 py-2" slot="footer">
  		<div>
		    <el-button @click="closeDrawerHandle">关闭</el-button>
	    </div>
  		<div class="flex-1">
	    	<el-button type="primary" @click="submitForm('rowData')">保存</el-button>
	    </div>
  	</div>
</el-dialog>
{/block}
{block name="script"}
{js href="__PLUGIN_SRC__/Xlsx/xlsx.core.min.js"}
{js href="__PLUGIN_SRC__/Xlsx/xlsx.utils.min.js"}
<script type="text/javascript">
	{empty name="vip"}
	var vip=[];
	{else/}
	var vip={:json_encode($vip,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="arealist"}
	var arealist=[];
	{else/}
	var arealist={:json_encode($arealist,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="attestation"}
	var attestation=[];
	{else/}
	var attestation={:json_encode($attestation,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="nature"}
	var nature=[];
	{else/}
	var nature={:json_encode($nature,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="finance"}
	var finance=[];
	{else/}
	var finance={:json_encode($finance,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="industry"}
	var industry=[];
	{else/}
	var industry={:json_encode($industry,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="size_type"}
	var size_type=[];
	{else/}
	var size_type={:json_encode($size_type,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="corporate_welfare"}
	var corporate_welfare=[];
	{else/}
	var corporate_welfare={:json_encode($corporate_welfare,JSON_UNESCAPED_UNICODE)};
	{/empty}
</script>
<script type="text/javascript">
	var personsDataObj=[];
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			labelPosition:'right',
			activeName:'user',
			rowData:{
				mobile:'',
				password:'',
				title:'',
				stitle:'',
				business_license:'',
				logo:'',
				attestation:'',
				nature:'',
				finance:'',
				industry_id:'',
				region_id:'',
				size_type:'',
				registered_capital:'',
				registered_capital_type:0,
				corporate_welfare:[],
				contacts:'',
				contacts_mobile:'',
				contacts_tel:'',
				contacts_email:'',
				contacts_area:[],
				contacts_address:'',
				company_website:'',
				company_introduction:'',
				company_descript:'',
				template_id:'',
				vip_level:0,
				vip_time:'',
			},
			rowDataFind:null,
			drawerHandle:false,
			vip:vip,
			arealist:arealist,
			attestation:attestation,
			nature:nature,
			finance:finance,
			industry:industry,
			size_type:size_type,
			corporate_welfare:corporate_welfare,
			business_license:'',
			logo:'',
			multipleSelectionIndex:null,
			multipleSelection:[],
			search:{
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			personsData:[],
			tableData:[],
			tel:{},
      defaultProps: {
        	value: 'id',
        	label: 'title',
        	children: 'data',
      },
      rules: {
        mobile: [
          { required: true, message: '请输入用户手机号', trigger: 'blur' },
        ],
        title: [
          { required: true, message: '请输入企业名称', trigger: 'blur' },
        ],
        attestation: [
          { required: true, message: '请选择企业认证状态', trigger: 'blur' },
        ],
        nature: [
          { required: true, message: '请选择企业性质', trigger: 'blur' },
        ],
        finance: [
          { required: true, message: '请选择融资阶段', trigger: 'blur' },
        ],
        industry_id: [
          { required: true, message: '请选择行业', trigger: 'blur' },
        ],
        size_type: [
          { required: true, message: '请选择公司规模', trigger: 'blur' },
        ],
        registered_capital: [
          { required: true, message: '请输入注册资金', trigger: 'blur' },
        ],
        contacts: [
          { required: true, message: '请输入联系人', trigger: 'blur' },
        ],
        contacts_mobile: [
          { required: true, message: '请输入联系人手机号', trigger: 'blur' },
        ],
        contacts_area: [
          { required: true, message: '请选择公司地址', trigger: 'blur' },
        ],
        contacts_address: [
          { required: true, message: '请输入公司地址', trigger: 'blur' },
        ],
        company_introduction: [
          { required: true, message: '请输入公司简介', trigger: 'blur' },
        ],
        company_descript: [
          { required: true, message: '请输入公司介绍', trigger: 'blur' },
        ],
      }
		},
		watch:{
		    view:XYBase.viewWatch,
		    tel:{
				handler(val,oldVal){
					if (val.area_code && val.number) {
						this.rowData.contacts_tel=val.area_code+'-'+val.number;
						if (val.extension) 
							this.rowData.contacts_tel=val.area_code+'-'+val.number+'-'+val.extension
					}else{
						this.rowData.contacts_tel='';
					}
				},
				deep:true
			},
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
	    toggleSelection(rows) {
	        if (rows) {
	          rows.forEach(row => {
	            this.$refs.tableList.toggleRowSelection(row);
	          });
	        } else {
	          this.$refs.tableList.clearSelection();
	        }
	    },
	    handleSelectionChange(val) {
	        this.multipleSelection = val;
	    },
			handleSizeChange(val) {
				this.search.page=1;
				this.search.pageSize=val;
	      this.pageHtml();
			},
			handleCurrentChange(val) {
				this.search.page=val;
	      this.pageHtml();
			},
			addCompanyALL(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.addCompanyALLAjax();
			},
			addCompanyALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					D=D.saveData;
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/company/addCompany',
						type:'post',
						data:D,
						dataType:'json',
						error:function(err){
				      loading.close();
							_this.multipleSelectionIndex=0;
					    _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].status=3;
								}else{
									_this.multipleSelection[_this.multipleSelectionIndex].status=4;
									_this.multipleSelection[_this.multipleSelectionIndex].errorMessage=ret.msg;
								}
							}else{
								_this.multipleSelection[_this.multipleSelectionIndex].status=4;
								_this.multipleSelection[_this.multipleSelectionIndex].errorMessage=XYBase.config.system_network_error;
							}
							_this.multipleSelectionIndex++;
							_this.addCompanyALLAjax();
						}
					})
				}else{
		      loading.close();
					_this.multipleSelectionIndex=0;
			    _this.$refs.tableList.clearSelection();
				}
			},
			initHtml() {
				for (var i = 0; i < this.multipleSelection.length; i++) {
					this.matchingCompany(this.multipleSelection[i]);
				}
			},
    	closeDrawerHandle(done){
    		this.rowDataIndex=null;
    		this.rowData={
					mobile:'',
					password:'',
					title:'',
					stitle:'',
					business_license:'',
					logo:'',
					attestation:'',
					nature:'',
					finance:'',
					industry_id:'',
					region_id:'',
					size_type:'',
					registered_capital:'',
					registered_capital_type:0,
					corporate_welfare:[],
					contacts:'',
					contacts_mobile:'',
					contacts_tel:'',
					contacts_email:'',
					contacts_area:[],
					contacts_address:'',
					company_website:'',
					company_introduction:'',
					company_descript:'',
					template_id:'',
					vip_level:0,
					vip_time:'',
				};
    		this.business_license='';
    		this.logo='';
				this.tel={
						area_code:'',
						number:'',
						extension:'',
					};
    		typeof done==='function'&&done();
				this.drawerHandle=false;
    	},
			handleAvatarSuccess:function(res, file) {
				if(res){
					if(res.code === 0){
						if(res.data.type == 'company/business_license'){
							this.rowData.business_license=res.data.path;
							this.business_license=res.data.url;
						}else if(res.data.type == 'company/logo'){
							this.rowData.logo=res.data.path;
							this.logo=res.data.url;
						}
						XYBase.success(res.msg);
					}else{XYBase.error(res.msg);}
				}else{XYBase.error(XYBase.config.system_network_error)}
			},
			handleAvatarError:function(res, file) {
	          	XYBase.error(XYBase.config.system_network_error)
			},
			editCompany(spoce){
				this.rowDataIndex=spoce.$index;
				this.rowData=spoce.row.saveData;
				if (spoce.row.saveData.business_license)
					this.business_license='{:config('web.imgurl')}'+spoce.row.saveData.business_license
				if (spoce.row.saveData.logo)
					this.logo='{:config('web.imgurl')}'+spoce.row.saveData.logo;
				if (spoce.row.saveData.contacts_tel) {
					var telArr=spoce.row.saveData.contacts_tel.split('-');
					this.tel={
							area_code:telArr[0],
							number:telArr[1],
							extension:telArr[2]?telArr[2]:'',
						};
				}else{
					this.tel={
							area_code:'',
							number:'',
							extension:'',
						};
				}
				this.drawerHandle=true;
			},
			submitForm(formName) {
				var _this=this;
				var row=_this.tableData[_this.rowDataIndex];
				_this.$refs[formName].validate((valid) => {
				  if (valid) {
						row.mobile=_this.rowData.mobile;
						row.title=_this.rowData.title;
						row.stitle=_this.rowData.stitle;
						row.nature=_this.getNatureText(_this.rowData.nature);
						row.industry=_this.getIndustry(_this.rowData.industry_id);
						row.finance=_this.getFinanceText(_this.rowData.finance);
						row.size_type=_this.getSizeTypeText(_this.rowData.size_type);
						row.registered_capital=_this.rowData.registered_capital+''+(_this.rowData.registered_capital_type?'万美元':'万人民币');
						row.company_introduction=_this.rowData.company_introduction;
						row.company_descript=_this.rowData.company_descript;
						row.contacts=_this.rowData.contacts;
						row.contacts_mobile=_this.rowData.contacts_mobile;
						row.contacts_tel=_this.rowData.contacts_tel;
						row.contacts_email=_this.rowData.contacts_email;
						row.area=_this.getAreaText(_this.rowData.contacts_area);
						row.contacts_address=_this.rowData.contacts_address;
				  	row.saveData=_this.rowData;
				  	_this.verificationRowData(row);
					} else {
						XYBase.warning('请先把表单填写完整。');
				    return false;
				  }
				});
			},
			matchingCompany(val){
				var nature=this.getNature(val.nature);
				var finance=this.getFinance(val.finance);
				var size_type=this.getSizeType(val.size_type);
				var industry_id=this.getIndustryId(val.industry);
				var registered=val.registered_capital.split('万');
				var area=this.getArea(val.area);
				val.saveData={
					mobile:val.contacts_mobile,
					password:'',
					title:val.title,
					stitle:val.stitle,
					business_license:'',
					logo:'',
					attestation:0,
					nature:nature,
					finance:finance,
					industry_id:industry_id,
					region_id:'',
					size_type:size_type,
					registered_capital:registered[0],
					registered_capital_type:registered[1]=='美元'?1:0,
					corporate_welfare:[],
					contacts:val.contacts,
					contacts_mobile:val.contacts_mobile,
					contacts_tel:val.contacts_tel,
					contacts_email:val.contacts_email,
					contacts_area:area,
					contacts_address:val.contacts_address,
					company_website:'',
					company_introduction:val.company_introduction,
					company_descript:val.company_descript,
					template_id:'',
					vip_level:0,
					vip_time:'',
				};
				this.verificationRowData(val);
			},
			verificationRowData(val){
				val.dataMessage=[];
				if (!val.saveData.mobile)
				val.dataMessage.push('手机号不能为空');
				if (!val.saveData.title)
				val.dataMessage.push('企业名称不能为空');
				if (val.saveData.nature==='')
				val.dataMessage.push('企业性质匹配失败');
				if (val.saveData.finance==='')
				val.dataMessage.push('融资阶段匹配失败');
				if (val.saveData.size_type==='')
				val.dataMessage.push('企业规模匹配失败');
				if (val.saveData.industry_id==='')
				val.dataMessage.push('所属行业匹配失败');
				if (!val.saveData.registered_capital)
				val.dataMessage.push('注册资金匹配失败');
				if (val.saveData.contacts_area.length<3)
				val.dataMessage.push('所在地区匹配失败');
				if (!val.saveData.contacts)
				val.dataMessage.push('联系人不能为空');
				if (!val.saveData.contacts_mobile)
				val.dataMessage.push('联系电话不能为空');
				if (!val.saveData.contacts_address)
				val.dataMessage.push('详细地址不能为空');
				if (!val.saveData.company_introduction)
				val.dataMessage.push('公司简介不能为空');
				if (!val.saveData.company_descript)
				val.dataMessage.push('公司介绍不能为空');
				if(val.dataMessage.length){
					val.status=2;
				}else{
					val.status=1;
				}
				this.closeDrawerHandle();
			},
			getArea(area){
				var ret=[];
				area=area.split('·');
				for (var i = 0; i < this.arealist.length; i++) {
					if (this.arealist[i].title.includes(area[0])) {
						ret.push(this.arealist[i].id);
						for (var j = 0; j < this.arealist[i].data.length; j++) {
							if (this.arealist[i].data[j].title.includes(area[1])) {
								ret.push(this.arealist[i].data[j].id);
								for (var n = 0; n < this.arealist[i].data[j].data.length; n++) {
									if (this.arealist[i].data[j].data[n].title.includes(area[2]))
									ret.push(this.arealist[i].data[j].data[n].id);
								}
							}
						}
					}
				}
				return ret;
			},
			getAreaText(area) {
				var areaText=[];
				for (var i = 0; i < this.arealist.length; i++) {
					if (area[0]===this.arealist[i].id) {
						areaText.push(this.arealist[i].title);
						for (var j = 0; j < this.arealist[i].data.length; j++) {
							if (area[1]===this.arealist[i].data[j].id) {
								areaText.push(this.arealist[i].data[j].title);
								for (var n = 0; n < this.arealist[i].data[j].data.length; n++) {
									if (area[2]===this.arealist[i].data[j].data[n].id)
									areaText.push(this.arealist[i].data[j].data[n].title);
								}
							}
						}
					}
				}
				return areaText.join('·');
			},
			getNature(str) {
				var ret='';
				for (var x in this.nature) {
					if (this.nature[x].title.includes(str)) {
						ret=this.nature[x].value;
						break;
					}
				}
				return ret;
			},
			getNatureText(value) {
				var ret='';
				for (var x in this.nature) {
					if (this.nature[x].value==value) {
						ret=this.nature[x].title;
						break;
					}
				}
				return ret;
			},
			getFinance(str) {
				var ret='';
				for (var x in this.finance) {
					if (this.finance[x].title.includes(str)) {
						ret=this.finance[x].value;
						break;
					}
				}
				return ret;
			},
			getFinanceText(value) {
				var ret='';
				for (var x in this.finance) {
					if (this.finance[x].value==value) {
						ret=this.finance[x].title;
						break;
					}
				}
				return ret;
			},
			getSizeType(str) {
				var ret='';
				for (var x in this.size_type) {
					if (this.size_type[x].title.includes(str)) {
						ret=this.size_type[x].value;
						break;
					}
				}
				return ret;
			},
			getSizeTypeText(value) {
				var ret='';
				for (var x in this.size_type) {
					if (this.size_type[x].value==value) {
						ret=this.size_type[x].title;
						break;
					}
				}
				return ret;
			},
			getIndustryId(str) {
				var ret='';
				for (var x in this.industry) {
					if (this.industry[x].title.includes(str)) {
						ret=this.industry[x].id;
						break;
					}
				}
				return ret;
			},
			getIndustry(id) {
				var ret='';
				for (var x in this.industry) {
					if (this.industry[x].id==id) {
						ret=this.industry[x].title;
						break;
					}
				}
				return ret;
			},
			pageHtml() {
				this.tableData=[];
		    for (var i = this.search.pageSize*(this.search.page-1); i < this.search.pageSize*this.search.page; i++) {
		    	if (typeof this.personsData[i]==='undefined') break;
		    	var val=this.personsData[i];
		    	var data={
						mobile:val['联系电话'],
		    		title:val['企业名称'],
						stitle:val['企业简称'],
						nature:val['企业性质'],
						industry:val['所属行业'],
						finance:val['融资阶段'],
						size_type:val['企业规模'],
						registered_capital:val['注册资金'],
						company_introduction:val['公司简介'],
						company_descript:val['公司介绍'],
						contacts:val['联系人'],
						contacts_mobile:val['联系电话'],
						contacts_tel:val['固定电话'],
						contacts_email:val['联系邮箱'],
						area:val['所在地区'],
						contacts_address:val['详细地址'],
						saveData:{
							mobile:'',
							password:'',
							title:'',
							stitle:'',
							business_license:'',
							logo:'',
							attestation:'',
							nature:'',
							finance:'',
							industry_id:'',
							region_id:'',
							size_type:'',
							registered_capital:'',
							registered_capital_type:0,
							corporate_welfare:[],
							contacts:'',
							contacts_mobile:'',
							contacts_tel:'',
							contacts_email:'',
							contacts_area:[],
							contacts_address:'',
							company_website:'',
							company_introduction:'',
							company_descript:'',
							template_id:'',
							vip_level:0,
							vip_time:'',
						},
						status:0
		    	};
		    	this.tableData.push(data);
		    }
			},
			readXlsx(e){
		    var fileReader = new FileReader();
		    fileReader.onload = function(ev) {
	        try {
	            var data = ev.target.result,
	                workbook = XLSX.read(data, {
	                    type: 'binary'
	                }); // 以二进制流方式读取得到整份excel表格对象
	                personsDataObj = []; // 存储获取到的数据
	        } catch (e) {
	            XYBase.error('文件类型不正确');
	            return;
	        }

	        // 表格的表格范围，可用于判断表头是否数量是否正确
	        var fromTo = '';
	        // 遍历每张表读取
	        for (var sheet in workbook.Sheets) {
	            if (workbook.Sheets.hasOwnProperty(sheet)) {
	                fromTo = workbook.Sheets[sheet]['!ref'];
	                personsDataObj = personsDataObj.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
	                break; // 如果只取第一张表，就取消注释这行
	            }
	        }
	        vm.personsData=personsDataObj;
	        vm.search.page=1;
					vm.search.total=vm.personsData.length;
					if (vm.search.total<1)
					return XYBase.error('文件内容为空');
					vm.pageHtml();
		    };
		    // 以二进制方式打开文件
		    fileReader.readAsBinaryString(e.raw);
			},
	    }
	});
	$(function(){
		reloadWindowSize();
		$(window).resize(function(){
			reloadWindowSize();
		});
	});
	function reloadWindowSize (argument) {
		var winW=$(window).width();
		if(winW <= 576){
			vm.labelPosition='top';
		}else{
			vm.labelPosition='right';
		}
	}
</script>
{/block}